#ifndef __APPLE_INCLUDE_MODULE_H__
#define __APPLE_INCLUDE_MODULE_H__

#include <core.h>
#include <apple_types.h>
#include <sysdep.h>

typedef struct _apple_module_t apple_module_t;
/*
 * Every entity in this level we thought as a module.
 * There are several type of module(e.g. terminal or graph).
 * Each module need tell system core level by call register_module.
 *
 * For extending we can have several mode such as dictionary or other.
 * The mode concept can classify the same class modules.
 * Now we can see this in module structure's type field. 
 */
struct _apple_module_t {
	const char *name;
	uint8_t type;
#define APPLE_MODULE_TYPE_DICT	0x01
#define APPLE_MODULE_TYPE_OTHER	0x02
	
	int (*init)(apple_module_t *m);	/* Init self things. e.g grah need open a window */
	void (*exit)(void);
	int (*start)(apple_module_t *m); /* Start up a module and wait it stop. */
	void *priv;	/* module private data. I know grah need a window. */
	list_t link;
};

int apple_module_init(void);
void apple_module_exit(void);
apple_module_t *apple_find_module(const char *name);

int module_call_mod_start(const char *name);
/* void module_call_mod_stop(const char *name); */

#endif /* __APPLE_INCLUDE_MODULE_H__ */

